import java.util.Arrays;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/10/13 14:04
 */

public class Main {
    public int minmumNumberOfHost (int n, int[][] startEnd) {
        int[] startTime = new int[n];
        int[] endTime = new int[n];

        // 活动的起始时间和结束时间
        for (int i = 0; i < n; i++) {
            startTime[i] = startEnd[i][0];
            endTime[i] = startEnd[i][1];
        }

        Arrays.sort(startTime);
        Arrays.sort(endTime);

        int host = 0, j = 0;

        for (int i = 0; i < n; i++) {
            // 新开始的节目大于上一轮结束的时间，主持人不变
            if (startTime[i] >= endTime[j]) {
                j++;
            } else {
                host++;
            }
        }
        return host;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[][] startEnd = new int[n][2];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 2; j++) {
                    startEnd[i][j] = in.nextInt();
                }
            }
            Main m = new Main();
            System.out.println(m.minmumNumberOfHost(n, startEnd));
        }
    }
}